{php $mylink_data = m('shop')->getCategory();}
<link href="../addons/ewei_shop/plugin/article/template/imgsrc/article.css" rel="stylesheet">
<!-- mylink start -->
    <div id="modal-mylink-goods" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog" style="width: 720px;">
            <div class="modal-content">
                <div class="modal-header" style="padding: 5px;">
                    <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                    <ul class="nav nav-pills" role="tablist">
                        
                        <li role="presentation" style="display: block;"><a aria-controls="link_goods" role="tab" data-toggle="tab" href="#link_goods" aria-expanded="false">商品</a></li>
                        
                    </ul>   
                </div>
                 <div class="modal-body tab-content">
                     

                    <div role="tabpanel" class="tab-pane link_goods" id="link_goods">
                         <div class="input-group">
                             <input type="text" class="form-control" name="keyword" value="" id="select-good-kw" placeholder="请输入商品名称进行搜索 (多规格商品不支持一键下单)">
                             <span class="input-group-btn"><button type="button" class="btn btn-default" id="select-good-btn">搜索</button></span>
                         </div>
                         <div class="mylink-con" id="select-goods" style="height:266px;"></div>
                     </div>
                     
                 </div>
            </div>
        </div>
    </div>
</div>

<!-- mylink end -->
<script language="javascript">

    $(function() {
        $("#chkoption").click(function() {
            var obj = $(this);
            if (obj.get(0).checked) {
                $("#tboption").show();
                $(".trp").hide();
            }
            else {
                $("#tboption").hide();
                $(".trp").show();
            }
        });
    })
    
    $(document).on("click",".nav-link-goods",function(){
        var id = $(this).data("id");
        if(id){
            $("#modal-mylink-goods").attr({"data-id":id});
            $("#modal-mylink-goods").modal();
        }
    });
    $(document).on("click",".mylink-nav-goods",function(){
        var name = $(this).data("name");
        var cid = $(this).data("id");
        var id = $("#modal-mylink-goods").attr("data-id");
        if(id){
            $("input[data-id="+id+"][data-name='goodsnames']").val(name);
            $("input[data-id="+id+"][data-name='goodsids']").val(cid);
            $("#modal-mylink-goods").attr("data-id","");
        }else{
            ue.execCommand('link', {href:href});
        }
        $("#modal-mylink-goods .close").click();
    });
    $(".mylink-nav-goods2").click(function(){
        var href = $("textarea[name=mylink_href").val();
        if(href){
            var id = $("#modal-mylink-goods").attr("data-id");
            if(id){
                $("input[data-id="+id+"]").val(href);
                $("#modal-mylink-goods").attr("data-id","");
            }else{
                ue.execCommand('link', {href:href});
            }
            $("#modal-mylink-goods .close").click();
            $("textarea[name=mylink_href").val(""); 
        }else{
            $("textarea[name=mylink_href").focus();
            alert("链接不能为空!");
        }
    });
    // ajax 选择商品
    $("#select-good-btn").click(function(){
        var kw = $("#select-good-kw").val();
        $.ajax({
            type: 'POST',
            url: "{php echo $this->createPluginWebUrl('article',array('method'=>'api','apido'=>'selectgoods'))}",
            data: {kw:kw},
            dataType:'json',
            success: function(data){
                //console.log(data);
                $("#select-goods").html("");
                if(data){
                    $.each(data,function(n,value){
                        var html = '<div class="good">';
                              html+='<div class="img"><img src="'+value.thumb+'"/></div>'
                              html+='<div class="choosebtn">';
                              html+='<a href="javascript:;" class="mylink-nav-goods" data-name="'+value.title+'" data-id="'+value.id+'">选择</a><br>';
                              
                              html+='</div>';
                              html+='<div class="info">';
                              html+='<div class="info-title">'+value.title+'</div>';
                              html+='<div class="info-price">原价:￥'+value.productprice+' 现价￥'+value.marketprice+'</div>';
                              html+='</div>'
                              html+='</div>';
                        $("#select-goods").append(html);
                    }); 
                }
           }
        });
    });
</script>